package io.renren.modules.lucky.service.impl;

import io.renren.common.utils.DateUtils;
import io.renren.modules.lucky.dao.AppStatDao;
import io.renren.modules.lucky.service.AppStatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.*;

@Service("AppStatService")
public class AppStatServiceImpl implements AppStatService {

    @Autowired
    private AppStatDao AppStatDao;

    @Override
    public Object getAppUserRegisterInfo(Map<String, Object> params) {
        Map<String, Object> map = new HashMap();
        List<Map<String, Object>> list = AppStatDao.getAppUserRegisterInfo(params);
        List<Object> dateList = new ArrayList<>();
        List<Object> countList= new ArrayList<>();
        if (!list.isEmpty()) {
            for (Map<String, Object> m: list) {
                dateList.add(m.get("date"));
                countList.add(m.get("count"));
            }
        }
        map.put("dateData", dateList);
        map.put("countData", countList);
        map.put("list", list);
        return map;
    }

    @Override
    public Object getAppGoodsLovesInfo(Map<String, Object> params) {
        Map<String, Object> map = new HashMap();
        List<Map<String, Object>> list = AppStatDao.getAppGoodsLovesInfo(params);
        List<Object> dateList = new ArrayList<>();
        List<Object> countList= new ArrayList<>();
        if (!list.isEmpty()) {
            for (Map<String, Object> m: list) {
                dateList.add(m.get("date"));
                countList.add(m.get("count"));
            }
        }
        map.put("dateData", dateList);
        map.put("countData", countList);
        map.put("list", list);
        return map;
    }

}
